package org.itboys.product.service;

import org.itboys.admin.entity.GoodsSourceDB;
import org.itboys.baseobject.entity.City;
import org.itboys.baseobject.service.CityService;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2016/6/13.
 */
@Service
public class GoodsSourceService extends BaseService<GoodsSourceDB, Long> {
	@Autowired
	private CityService cityService;
    @Resource(name="adminDS")
    private MongoDataSource ds;

    @Override
    protected MongoDataSource getMongoDataSource() {
        return ds;
    }

    @Override
    protected Class<GoodsSourceDB> getEntityClass() {
        return GoodsSourceDB.class;
    }

    public List<GoodsSourceDB> getAllSources() {
        return ds.createQuery(getEntityClass()).asList();
    }
    public String getSourceCityName(Long sourceId){
    	GoodsSourceDB source=getById(sourceId);
		if (null!=source) {
			return source.getName();
		}
		return "";
    }
}
